STEPPER MOTOR INTERFACING WITH AVR
There are two major types of stepper motors: Permanent magnet stepper motors (unipolar stepper motors and bipolar stepper motors) and variable reluctance stepper motors (hybrid stepper motors). In this we will discuss about both unipolar and bipolar stepper motors interfacing with AVR.
Synopsis

A stepper motor is a brushless, synchronous electric motor that converts digital pulses into mechanical shaft rotation. Every revolution of the stepper motor is divided into a discrete number of steps, and the motor must be sent a separate pulse for each step.

Programmable Counter Array (PCA) of the microcontroller ATmega16 uses to generate the control signals to the Power Interface. The Power Interface allows the microcontroller ATmega16 to drive enough current into coils of a stepper motor.

There are two advantages to using PCA. First of all, PCA provides greater accuracy than toggling pins in software because the toggle occurs before the interrupt request is serviced. Thus, interrupt response time does not affect the accuracy of the output. Secondly the ATmega16 microcontroller CPU is left free for application task execution while the PCA drives stepper motors.

There are two major types of stepper motors: Permanent magnet stepper motors (unipolar stepper motors and bipolar stepper motors) and variable reluctance stepper motors (hybrid stepper motors).

Description

Stepper motors are used in a wide variety of applications. They are prevalent in consumer office equipment such as printers, plotters, copiers, and Scanners. Stepper motors are also used in automotive applications for electronic throttle control, dashboard indicators, and climate control systems. Stepper motors are also found in industrial equipment such as robotics, electronic component handlers, testers, dispensers, and other manufacturing equipment. It is often controlled using special function ICs that provide limited control functionality.

Motor

There are several types of stepper motors, these cannot be driven in the same way. Unipolar Stepper Motor Unipolar stepper motors are characterized by their center-tapped windings.

Unipolar stepper motor

In the unipolar stepper motor, it works with one winding with a center tap per phase, each section of the phase winding is turned on for each of the magnetic field direction. Since unipolar stepper motors are quite easy to operate. Unlike dc motors, which spin round freely when power is applied, stepper motors require that their power supply be continuously pulsed in specific patterns. For each pulse, the stepper motor moves around one ‘step’, often 7.5 degrees (giving 48 steps in a full revolution).

As the stepper motor operates at 12V, the standard transistor circuit is required to switch each coil. As the coils create a back emf when switched off, a suppression diode on each coil is also required. The table below show the four different steps required to make the motor turn.

Coil 2 is always the opposite (or logical NOT) of coil 1. The same applies for coils 3 and 4. It is therefore possible to cut down the number of microcontroller PIC18F4550 pins required to just two by the use of two additional NOT gates.


Figure 1. Unipolar Stepper Motors Coils


Bipolar Stepper Motor

Bipolar stepper motors are designed with separate coils. The bipolar stepper motor has two coils that must be controlled so that the current flows in different directions through the coils in a certain order. The changing magnetic fields that these coils create cause the rotor of the motor to move around in steps.


Figure 2. Bipolar Stepper Motor Coils


Variable Reluctance stepper motor (also called hybrid motors) are characterized by one common lead.

Figure 3. Hybrid Stepper Motor Coils


The ULN2003A is a current driver IC. It is used to drive the current of the stepper motor as it requires more than 60mA of current. It is an array of Darlington pairs. It consists of seven pairs of Darlington arrays with common emitter. The IC consists of 16 pins in which 7 are input pins, 7 are output pins and remaining are VCC and Ground. The first four input pins are connected to the ATmega16 microcontroller. In the same way, four output pins are connected to the stepper motor.

Stepper motor has 6 pins. In these six pins, 2 pins are connected to the supply of 12V and the remaining is connected to the output of the stepper motor. Stepper rotates at a given step angle. Each step in rotation is a fraction of full cycle. This depends on the mechanical parts and the driving method.

Similar to all the motors, stepper motors will have stator and rotor. Rotor has permanent magnet and stator has coil. The basic stepper motor has 4 coils with 90 degrees rotation step. These four coils are activated in the cyclic order.

Step Angle

Step angle of the stepper motor is defined as the angle traversed by the motor in one step. To calculate step angle, simply divide 360 by number of steps a motor takes to complete one revolution. As we have seen that in half mode, the number of steps taken by the motor to complete one revolution gets doubled, so step angle reduces to half.

As in above examples, Stepper Motor rotating in full mode takes 4 steps to complete a revolution, So step angle can be calculated as...

Step Angle ø = 360° / 4 = 90°

and in case of half mode step angle gets half so 45°.

So this way we can calculate step angle for any stepper motor. Usually step angle is given in the spec sheet of the stepper motor you are using. Knowing stepper motor's step angle helps you calibrate the rotation of motor also to helps you move the motor to correct angular position.

Driving Unipolar Stepper Motors

Mainly there are 3 types of stepping modes in Unipolar stepper motors

Full step (One Phase on Mode, Two Phases on Mode)

Half step

Micro step

Full Step

In full step operation, each step has a movement of 1.8 degrees and hence it takes 200 steps to complete a full revolution. This is made possible by energising either single of stator winding or two phases. Since the two phases are energised at the same time in the dual phase operation, torque and speed are greater in this kind of operation while the single phase operation requires lower amount of power from the driver circuit.

There are two types of full step mode:

One step mode / wave step

Dual phase mode

In one step mode/ wave step, the motor is operated with only one phase energized at a time. This mode of operation requires small amount of power.

Table 1. One Phase on Sequence


Figure 4. One Phase Steps



In one phase mode, each successive coil is energized in turn. One phase mode produces smooth rotations and the lowest power consumption of the three modes. Steps are applied in order from one to four. After step four, the sequence is repeated from step one. Applying steps from one to four makes the motor run clockwise, reversing the order of step from four to one will make the motor run counter-clockwise.

Figure 5. One Phase on Steps Sequence


Two Phases on Mode (Alternate Full step Mode)

Table 2. Two Phases on Sequence


Figure 6. Two Phases on Steps




In two phase mode, successive pairs of adjacent coils are energized in turn, motion is not as smooth as in one phase mode, power consumption is more important but it produces greater torque. As in one phase mode, applying the steps in order makes the stepper motor run clockwise and reversing order makes it turn counter-clockwise.

Figure 7. Two Phases on Steps Sequence


Half Step Mode Table 3. Half Step Sequence


The half step sequence is a mix of one phase on and two phases on sequences. The main advantage of this mode is to increase by two the nominal number of steps of your stepper motor. By example, a unipolar stepper motor of 24 steps of 15 degrees each "becomes", when we use half step mode, a stepper motor of 48 steps of 7.5 degrees.

Figure 8. Half Step Sequence





Figure 9. Half Step Sequence


Micro step

In micro step mode, it divides the motor steps up to 256 times which improves the low speed smoothness and low speed resonance effects. But in this mode, motor produces less torque compared to other mode. In micro step operation, the basic angle is divided into minute values even up to 256 times. Microstep operation is preferred where increased smoothness of rotation is required.

Driving Bipolar Stepper Motors

Bi-polar stepper motors has 2 different coils. The step sequence for Bipolar stepper motor is same as that of unipolar stepper motors. The driving circuit for this require an H-Bridge as it allows the polarity of the power applied to be controlled independently.


Advantages

·  Excellent low speed torque  (Can drive many loads without gearing).

·  Excellent repeatability  (Returns to the same location accurately).

·  Overload safe  ( Motor cannot be damaged by mechanical overload).

Applications

Blood-oxygenating pumps

CT scanners

Air control valves

Head light adjustment motors

Proteus design for Unipolar Stepper Motor interfacing with AVR


Proteus design for Bipolar Stepper Motor interfacing with AVR


Orcad design for Unipolar Stepper Motor interfacing with AVR


Orcad design for Bipolar Stepper Motor interfacing with AVR


Unipolar Full drive Stepper Motor interfacing with AVR

/*  Name     : UARTmain.c
 *  Purpose  : Source code for Unipolar full step stepper motor interface with ATMEGA16.
 *  Author   : Gemicates
 *  Date     : 2017-09-09
 *  Website  : www.gemicates.org
 *  Revision : None
 */


#define F_CPU 8000000UL			// Define CPU Frequency e.g. here its 8MHz 
#include <avr/io.h>		        // Include AVR std. library file 
#include <util/delay.h>		        // Include delay header file 
#define lcd_clrscr()
	#define lcd_puts()

int main(void)
{
	int period;
	DDRD = 0x0F;			// Make PORTD lower pins as output 
	PORTD=0x00;
	period = 100;
   				        // Set period in between two steps of Stepper Motor 
	
	while (1)                       // Rotate Stepper Motor Anticlockwise with Full step sequence; Full step angle 90 degree 

	{

PORTD = 0x09;
_delay_ms(period);
PORTD = 0x0C;
_delay_ms(period);
PORTD = 0x06;
_delay_ms(period);
PORTD = 0x03;
_delay_ms(period);
}
}


Unipolar Half drive Stepper Motor interfacing with AVR

/*  Name     : main.c
 *  Purpose  : Source code for Unipolar half step stepper Motor interface with ATMEGA16.
 *  Author   : Gemicates
 *  Date     : 2017-09-11
 *  Website  : www.gemicates.org
 *  Revision : None
 */


#define F_CPU 8000000UL		  // Define CPU Frequency e.g. here its 8MHz 
#include <avr/io.h>	          // Include AVR std. library file 
#include <util/delay.h>		  // Include delay header file 
#define lcd_clrscr()
	#define lcd_puts()

int main(void)
{
	int period;
	DDRD = 0x0F;	          // Make PORTD lower pins as output 
	PORTD=0x00;
	period = 100;
   				  // Set period in between two steps of Stepper Motor 
	
	while (1)
	{
	  
	                          // Rotate Stepper Motor clockwise with Half step sequence; Half step angle 45 degree 
			
			
			PORTD = 0x09;
			_delay_ms(period);
			PORTD = 0x08;
			_delay_ms(period);
			PORTD = 0x0C;
			_delay_ms(period);
			PORTD = 0x04;
			_delay_ms(period);
			PORTD = 0x06;
			_delay_ms(period);
			PORTD = 0x02;
			_delay_ms(period);
			PORTD = 0x03;
			_delay_ms(period);
			PORTD = 0x01;
			_delay_ms(period);
			}

}
Unipolar Wave drive Stepper Motor interfacing with AVR

/*  Name     : main.c
 *  Purpose  : Source code for Unipolar wave drive stepper motor interface with ATMEGA16.
 *  Author   : Gemicates
 *  Date     : 2017-09-10
 *  Website  : www.gemicates.org
 *  Revision : None
 */

#define F_CPU 8000000UL			// Define CPU Frequency e.g. here its 8MHz 
#include <avr/io.h>		        // Include AVR std. library file 
#include <util/delay.h>		        // Include delay header file 
#define lcd_clrscr()
	#define lcd_puts()

int main(void)
{
	int period;
	DDRD = 0x0F;		        // Make PORTD lower pins as output 
	PORTD=0x00;
	period = 100;
   				        // Set period in between two steps of Stepper Motor 
	
	while (1)
	{
	  

PORTD = 0x08;
_delay_ms(period);
PORTD = 0x04;
_delay_ms(period);
PORTD = 0x02;
_delay_ms(period);
PORTD = 0x01;
_delay_ms(period);
}
}


Bipolar Stepper Motor interfacing with AVR

/*  Name     : main.c
 *  Purpose  : Source code for Bipolar stepper motor interface with ATMEGA16.
 *  Author   : Gemicates
 *  Date     : 2017-09-11
 *  Website  : www.gemicates.org
 *  Revision : None
 */

#define F_CPU 8000000UL			// Define CPU Frequency e.g. here its 8MHz 
#include <avr/io.h>			// Include AVR std. library file 
#include <util/delay.h>		        // Include delay header file 
int main(void)
{
	int period;
	DDRD = 0x0F;			// Make PORTD lower pins as output 
	PORTD=0x00;
	period = 100;
   				        // Set period in between two steps of Stepper Motor 

	   		
	
	while (1)    
	{
	  
	  

PORTD = 0x01;
_delay_ms(period);
PORTD = 0x04;
_delay_ms(period);
PORTD = 0x02;
_delay_ms(period);
PORTD = 0x08;
_delay_ms(period);
}
}


Error message here!

Show Error message here!


Forgot your password?

Error message here!

Send OTP

Error message here!

Show Error message here!


Lost your password? Please enter your email address. You will receive a password you Need.

Send Error message here!


Back to log-in

Close